package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.mapper.DtsCollectMapper;
import com.qf.pojo.DtsCollect;
import com.qf.service.DtsCollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @author 邢式瑞
 * @version 1.0
 * @project E-commercebackGroundManagementSystem
 * @date 2022/9/22 21:33
 */
@Service
public class DtsCollectServiceImpl  implements DtsCollectService {
    @Autowired
    private DtsCollectMapper dtsCollectMapper;
    @Override
    public Page<DtsCollect> selectPage(Integer page, Integer limit, String sort, String order, Integer userId, Integer valueId) {
        Page<DtsCollect> dtsCollectPage = new Page<>(page, limit);
        QueryWrapper<DtsCollect> dtsCollectQueryWrapper = new QueryWrapper<>();
        dtsCollectQueryWrapper.orderBy(!StringUtils.isEmpty(sort),"asc".equalsIgnoreCase(order),sort).eq(userId!=null,"user_id",userId).eq(valueId!=null,"value_id",valueId).eq("deleted",false);

        return dtsCollectMapper.selectPage(dtsCollectPage,dtsCollectQueryWrapper);
    }
}
